package org.ocean.general.sample.conditional;

import org.ocean.general.sample.constant.OptionalConstant;

public class Conditional<T> {
    public Builder<T> builder;

    public Builder<T> getBuilder() {
        return builder;
    }

    public void setBuilder(Builder<T> builder) {
        this.builder = builder;
    }

    public Conditional(Builder<T> builder){
        this.builder = builder;
    }

    public static Builder<?> builder(Class<?> bean) {
        return new Builder<>(bean);
    }

    public static class Builder<T>{
        public T bean;
        public Sqls sqls;
        public String where;

        public T getBean() {
            return bean;
        }

        public void setBean(T bean) {
            this.bean = bean;
        }

        public Sqls getSqls() {
            return sqls;
        }

        public void setSqls(Sqls sqls) {
            this.sqls = sqls;
        }

        public String getWhere() {
            return where;
        }

        public void setWhere(String where) {
            this.where = where;
        }

        public Builder(T bean){
            this.bean = bean;
        }


        public Conditional<T> build(){
            return new Conditional<>(this);
        }

        public  Builder<T> where(Sqls sqls) {
            this.sqls = sqls;
            this.where = OptionalConstant.WHERE;
            return this;
        }
    }
}
